package com.uhylab.uhuvinetest.activity;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;

import com.uhylab.uhuvinetest.R;
import com.uhylab.uhuvinetest.adapter.UHLineListAdapter;
import com.uhylab.uhuvinetest.base.UHBase;
import com.uhylab.uhuvinetest.base.UHBaseActivity;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 项目名称：Uhylab
 * 类描述：
 * 创建人：xyb
 * 创建时间：16/6/3 14:41
 * 修改人：xyb
 * 修改时间：16/6/3 14:41
 * 修改备注：
 */
public class UHTrendActivity extends UHBaseActivity implements AdapterView.OnItemClickListener  {


    @BindView(R.id.trend_back)
    ImageView mTrendBack;
    @BindView(R.id.trend_list)
    ListView mTrendList;


    private ArrayList<String> mStrings;


    @Override
    public int bindLayout() {
        return R.layout.activity_trend;
    }

    @Override
    public void initView(View view) {
        ButterKnife.bind(this);
    }

    @Override
    public void doBusiness(Context mContext) {
        mStrings = new ArrayList<>();
        String[] strings = {
                "白细胞", "亚硝酸盐", "尿胆原", "蛋白质", "酸碱度", "潜血", "比重", "酮体", "胆红素", "葡萄糖", "抗坏血酸"
        };

        for (String s :
                strings) {
            mStrings.add(s);
        }



        UHLineListAdapter adapter = new UHLineListAdapter(this, mStrings);

        if (adapter == null) {
            Log.e("TAG","nullllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll");
        }


        mTrendList.setAdapter(adapter);
        mTrendList.setOnItemClickListener(this);
    }

    @Override
    public void resume() {

    }

    @Override
    public void destroy() {

    }


    @OnClick(R.id.trend_back)
    public void onClick() {
        finish();
    }

    /**
     * listView 行布局点击事件
     *
     * @param parent
     * @param view
     * @param position
     * @param id
     */
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        String itemAtPosition = (String) parent.getItemAtPosition(position);
        Intent intent = new Intent(this, UHCharWebActivity.class);
        intent.putExtra("title", itemAtPosition);
        intent.putExtra("position", position);
        String describe = UHBase.describe[position];
        intent.putExtra("describe", describe);
        startActivity(intent);
    }

}
